/* 
 * Pascal's Triangle
 */

#include "../func.h"

vector<vector<int>> generate(int numRows) {
    vector<vector<int>> result;
    if (0 == numRows)
        return result;

    result.push_back(vector<int>(1, 1));
    for (int i = 2; i <= numRows; ++i) {
        vector<int> current(i, 1);
        vector<int> &prev = result[i-2];
        for (int j = 1; j < i - 1; ++j) {
            current[j] = prev[j-1] + prev[j];
        }
        result.push_back(current);
    }
    return result;
}